//
//  BySetPayPasswardSetp1VC.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/24.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "BySetPayPasswardSetp1VC.h"

// vc
#import "BySetPayPasswardSetp2VC.h"

@interface BySetPayPasswardSetp1VC ()

@end

@implementation BySetPayPasswardSetp1VC
{
    UILabel     *_noteLabel;        // 注释
    UILabel     *_prefixLabel;      // 前缀（+86）
    UITextField *_mobileTf;         // 手机输入框
    UITextField *_codeTf;           // 验证码输入框
    UIButton    *_fetchCodeButton;  // 获取验证码按钮
    
    UIButton    *_nextButton;       // 下一步
}
#pragma mark - view method
- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"设置交易密码";
    self.view.backgroundColor = BY_BG_COLOR;
    
    [self addLeftBackBarButtonItem];
    
    [self createViews];
}


#pragma mark - 创建视图
- (void)createViews {
    
    // 注释
    _noteLabel = [[UILabel alloc] init];
    _noteLabel.adjustsFontSizeToFitWidth = true;
    _noteLabel.numberOfLines = 1;
    _noteLabel.text = @"为了您的账户安全，请设置您的交易密码";
    _noteLabel.font = FONT(16);
    _noteLabel.textAlignment = NSTextAlignmentCenter;
    _noteLabel.textColor = BY_RED_COLOR;
    [self.view addSubview:_noteLabel];
    
    // 前缀
    _prefixLabel = [[UILabel alloc] init];
    _prefixLabel.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
    _prefixLabel.adjustsFontSizeToFitWidth = true;
    _prefixLabel.numberOfLines = 1;
    _prefixLabel.text = @"+86";
    _prefixLabel.font = FONT(24);
    _prefixLabel.textAlignment = NSTextAlignmentCenter;
    _prefixLabel.textColor = [UIColor whiteColor];
    _prefixLabel.layer.cornerRadius = 4;
    _prefixLabel.layer.masksToBounds = true;
    [self.view addSubview:_prefixLabel];
    
    // 手机输入
    _mobileTf = [UITextField new];
    _mobileTf.layer.cornerRadius = 4;
    _mobileTf.backgroundColor = [UIColor whiteColor];
    _mobileTf.placeholder = @"请输入手机号";
    _mobileTf.font = FONT(18);
    _mobileTf.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_mobileTf];
    
    // 验证码输入
    _codeTf = [UITextField new];
    _codeTf.layer.cornerRadius = 4;
    _codeTf.backgroundColor = [UIColor whiteColor];
    _codeTf.placeholder = @"请输入验证码";
    _codeTf.font = FONT(18);
    _codeTf.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_codeTf];
    
    // 获取验证码
    _fetchCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _fetchCodeButton.titleLabel.font = FONT(18);
    _fetchCodeButton.backgroundColor = BY_THEME_COLOR;
    _fetchCodeButton.layer.cornerRadius = 4;
    [_fetchCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    [_fetchCodeButton setTitleColor:BY_GOLD_COLOR forState:UIControlStateNormal];
    [_fetchCodeButton addTarget:self action:@selector(fetchCode) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_fetchCodeButton];
    
    // 下一步
    _nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _nextButton.titleLabel.font = FONT(18);
    _nextButton.backgroundColor = BY_THEME_COLOR;
    _nextButton.layer.cornerRadius = 4;
    [_nextButton setTitle:@"下一步" forState:UIControlStateNormal];
    [_nextButton setTitleColor:BY_GOLD_COLOR forState:UIControlStateNormal];
    [_nextButton addTarget:self action:@selector(nextStep) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_nextButton];
    
    
    // 布局
    [_noteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@60);
        make.left.top.right.equalTo(self.view);
    }];
    [_prefixLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(15);
        make.top.equalTo(_noteLabel.mas_bottom);
        make.height.equalTo(@50);
    }];
    [_mobileTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_prefixLabel.mas_right).offset(10);
        make.width.equalTo(_prefixLabel.mas_width).multipliedBy(2);
        make.right.equalTo(self.view).offset(-15);
        make.height.top.equalTo(_prefixLabel);
    }];
    [_codeTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_prefixLabel);
        make.top.equalTo(_prefixLabel.mas_bottom).offset(10);
        make.height.equalTo(_prefixLabel);
    }];
    [_fetchCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_codeTf.mas_right).offset(10);
        make.width.equalTo(_codeTf.mas_width).multipliedBy(0.5);
        make.right.equalTo(self.view).offset(-15);
        make.height.top.equalTo(_codeTf);
    }];
    [_nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_codeTf);
        make.right.equalTo(_fetchCodeButton);
        make.height.equalTo(_fetchCodeButton);
        make.top.equalTo(_fetchCodeButton.mas_bottom).offset(100);
    }];
}

#pragma mark - 点击事件
- (void)fetchCode {
    
}
- (void)nextStep {
    
    [self by_normalPush:[BySetPayPasswardSetp2VC new] hasNavi:true];
}




@end
